/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package entities;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author riccardo
 */
@Entity
@Table(name = "VOLO")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Volo.findAll", query = "SELECT v FROM Volo v"),
    @NamedQuery(name = "Volo.findByIdVOLO", query = "SELECT v FROM Volo v WHERE v.idVOLO = :idVOLO"),
    @NamedQuery(name = "Volo.findByPrezzo", query = "SELECT v FROM Volo v WHERE v.prezzo = :prezzo"),
    @NamedQuery(name = "Volo.findByData", query = "SELECT v FROM Volo v WHERE v.data = :data"),
    @NamedQuery(name = "Volo.findByDurata", query = "SELECT v FROM Volo v WHERE v.durata = :durata")})
public class Volo implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "idVOLO")
    private Integer idVOLO;
    @Basic(optional = false)
    @NotNull
    @Column(name = "prezzo")
    private int prezzo;
    @Basic(optional = false)
    @NotNull
    @Column(name = "data")
    @Temporal(TemporalType.DATE)
    private Date data;
    @Basic(optional = false)
    @NotNull
    @Column(name = "durata")
    @Temporal(TemporalType.TIME)
    private Date durata;
    @JoinColumn(name = "idVOLO", referencedColumnName = "idELEMENTO", insertable = false, updatable = false)
    @OneToOne(optional = false)
    private Elemento elemento;
    @JoinColumn(name = "compagnia", referencedColumnName = "idCOMPAGNIA")
    @ManyToOne(optional = false)
    private Compagnia compagnia;
    @JoinColumn(name = "arrivo", referencedColumnName = "CAP")
    @ManyToOne(optional = false)
    private Citta arrivo;
    @JoinColumn(name = "partenza", referencedColumnName = "CAP")
    @ManyToOne(optional = false)
    private Citta partenza;

    public Volo() {
    }

    public Volo(Integer idVOLO) {
        this.idVOLO = idVOLO;
    }

    public Volo(Integer idVOLO, int prezzo, Date data, Date durata) {
        this.idVOLO = idVOLO;
        this.prezzo = prezzo;
        this.data = data;
        this.durata = durata;
    }

    public Integer getIdVOLO() {
        return idVOLO;
    }

    public void setIdVOLO(Integer idVOLO) {
        this.idVOLO = idVOLO;
    }

    public int getPrezzo() {
        return prezzo;
    }

    public void setPrezzo(int prezzo) {
        this.prezzo = prezzo;
    }

    public Date getData() {
        return data;
    }

    public void setData(Date data) {
        this.data = data;
    }

    public Date getDurata() {
        return durata;
    }

    public void setDurata(Date durata) {
        this.durata = durata;
    }

    public Elemento getElemento() {
        return elemento;
    }

    public void setElemento(Elemento elemento) {
        this.elemento = elemento;
    }

    public Compagnia getCompagnia() {
        return compagnia;
    }

    public void setCompagnia(Compagnia compagnia) {
        this.compagnia = compagnia;
    }

    public Citta getArrivo() {
        return arrivo;
    }

    public void setArrivo(Citta arrivo) {
        this.arrivo = arrivo;
    }

    public Citta getPartenza() {
        return partenza;
    }

    public void setPartenza(Citta partenza) {
        this.partenza = partenza;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idVOLO != null ? idVOLO.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Volo)) {
            return false;
        }
        Volo other = (Volo) object;
        if ((this.idVOLO == null && other.idVOLO != null) || (this.idVOLO != null && !this.idVOLO.equals(other.idVOLO))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.Volo[ idVOLO=" + idVOLO + " ]";
    }
    
}
